
import requests


headers = {
    "accept": "application/json, text/javascript, */*; q=0.01",
    "accept-language": "zh-CN,zh;q=0.9",
    "cache-control": "no-cache",
    "pragma": "no-cache",
    "priority": "u=1, i",
    "referer": "https://www.zhipin.com/chengshi/c101180700/?ka=char_select_city_101180700",
    "sec-ch-ua": "\"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-origin",
    "traceid": "F-741bb9PLVIqS5MtW",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
    "x-requested-with": "XMLHttpRequest"
}
cookies = {
    "__g": "-",
    "Hm_lvt_194df3105ad7148dcf2b98a91b5e727a": "1732068098",
    "HMACCOUNT": "AFD53293F7A60F46",
    "ab_guid": "d0c2b0aa-a4cb-44b0-9104-29c4a04afa49",
    "__zp_seo_uuid__": "a170f06e-ddb4-4813-b440-ba171fff6558",
    "__l": "r=https%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3DWpJU6dEYP5heX4pHJRfIcqqNzk0_vr0I8wQXRF_kZquO5dJ8WE3OoYcrrdIA1rRI%26wd%3D%26eqid%3Dcc53747d00be172f00000006674577ae&l=%2F&s=1",
    "lastCity": "101180700",
    "Hm_lpvt_194df3105ad7148dcf2b98a91b5e727a": "1732607437",
    "__c": "1732068098",
    "__a": "93400528.1732068098..1732068098.21.1.21.21",
    "__zp_stoken__": "c1befw4pqVgc0XQhhVhJlbFPCtndlaMKjV2fCgcKqbMKjc8Krf01cwqzCv2LCvERSwrzCt8KdVU9Jw7PCp8O5wqjCjGDCjMKbwojCq8Otwq7CoMSWw6VSw6LEucOCwrTCnjQmBgoJAw0GCgkDDQgEDBIIDwsMEggGCgkDDTMvwoQ%2BPjY9MydIT0sFS1ddRGJHEVNDRjk7EQ4OCTsvasKzwrU%2FOMK9XsK2csK%2FwrTCtynCuMK4wrgLOTc4NMK6w4osPCIHwrnCuwQWB8K0JwQwB8OJWMKBwrXDq8KzPSw6OcK5xYBBORU%2FPjU7OjQ3NTklNCHDiFt%2BwrjDp8K2cCo5Hj05Ojs8NTk6PT4%2FJTpCCic5Myk6BAgKBAcmPsK3w4HCv8OgOTo%3D"
}
url = "https://www.zhipin.com/wapi/zpCommon/data/city.json"
response = requests.get(url, headers=headers, cookies=cookies)

res = response.json()
print(res)
city_list = res['zpData']['cityList']
for city in city_list:
    province = city['name']
    province_id = city['code']
    level_list = city['subLevelModelList']
    for level in level_list:
        level_name = level['name']
        level_id = level['code']
        region_list = level['subLevelModelList']
        for region in region_list:
            region_name = region['name']
            region_id = region['code']